package com.springbootsecuritydemo.controller;

import com.springbootsecuritydemo.entity.ResponseResult;
import com.springbootsecuritydemo.service.impl.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户登录控制层
 *
 * @author Daft_V
 * @date 2022/4/12 17:47
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/login")
    @ResponseBody
    public ResponseResult login(String username, String password) {
        return userService.login(username, password);
    }

    @GetMapping("/logout")
    @ResponseBody
    public ResponseResult logout() {
        return userService.logout();
    }

    @GetMapping("/zhuce")
    @ResponseBody
    public String zhuce(String username,String password){
        userService.zhuce(username,password);
        return "success";
    }
}
